Skip to content

feat: align Layout::NZ inference with pto-isa 5D form - #1027

Open
HecreReed wants to merge 9 commits into
hw-native-sys:mainfrom
HecreReed:codex/issue527-nz-layout-design
Open

feat: align Layout::NZ inference with pto-isa 5D form#1027
HecreReed wants to merge 9 commits into
hw-native-sys:mainfrom
HecreReed:codex/issue527-nz-layout-design

Conversation

@HecreReed

@HecreReed HecreReed commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Align PTOAS Layout::NZ resolution with the canonical pto-isa 5D representation. This PR now contains the complete issue #527 change: design, implementation, tests, and user documentation.

Implemented behavior

  • Treat explicit ND / DN / NZ as authoritative.
  • Infer NZ from an unannotated root view only when it matches the canonical non-degenerate pto-isa 5D convention.
  • Use separate checks for canonical NZ roots and layout-preserving NZ subviews.
  • Preserve NZ across partition_view / memref.subview only when the inner fractal remains intact.
  • Support nested partition_view layout inheritance.
  • Remove the legacy off-by-one NZ rule without a compatibility flag.
  • Centralize verifier, inference-pass, and EmitC layout resolution in PTOLayoutUtils.

Validation

  • Shared layout utilities and call-site migration.
  • Verifier, propagation, negative-diagnostic, and regression tests.
  • A3/A5 compile coverage.
  • Latest-main PTO regression suite: 1430 discovered, 1429 passed, 1 platform-unsupported, 0 failed.
  • Executable PTODSL documentation example.
  • Board validation when compatible hardware is available.

Closes #527

Design proposal for issue hw-native-sys#527. PTOAS currently infers Layout::ND for the
canonical pto-isa 2D NZ 5D view ([1, cols/C0, rows/16, 16, C0]) and infers
Layout::NZ for a contiguous ND view that happens to match an off-by-one-dim
pattern. The doc analyses the root cause, states why shape/stride alone cannot
distinguish NZ from a contiguous ND 5D view, proposes a single shared
inference utility with an explicit-layout-wins policy plus a guarded canonical
pattern rule, and reports the measured blast radius over the lit corpus.

No behavior change in this commit (docs only).
@HecreReed HecreReed changed the title docs: design for aligning Layout::NZ inference with the pto-isa 5D form (#527) feat: align Layout::NZ inference with pto-isa 5D form Jul 28, 2026
@HecreReed
HecreReed marked this pull request as ready for review July 28, 2026 12:11
@HecreReed

Copy link
Copy Markdown
Collaborator Author

/run a3

@reedhecre

Copy link
Copy Markdown

已接收 /run a3,A3 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A3 板测失败

  • 触发方式:manual
  • 源码提交:d94d5c41bd54
  • 结果汇总:OK 217 / FAIL 3 / SKIP 3
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260728_230819_manual_pr1027.log
  • 手动指令:/run a3
  • 触发人:HecreReed
  • 触发评论:feat: align Layout::NZ inference with pto-isa 5D form #1027 (comment)
  • 失败阶段:board-validation / exit=1

失败用例

  • syncall_binding (run, exit=2)
  • comm_p2p_binding_variants (run, exit=1)
  • comm_p2p (run, exit=1)

@reedhecre

Copy link
Copy Markdown

A3 板测失败详情:PR #1027

syncall_binding

stage=run info=exit=2

/home/zhongxuan/ptoas-board-monitor/runtime/runs/20260728_230819_manual_pr1027/npu_validation/SyncAll/syncall_binding/syncall_binding_kernel.cpp:96:3: error: no matching function for call to 'SYNCALL'
  SYNCALL<SyncAllMode::Soft, SyncCoreType::AIVOnly>(v8, v10, v2);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhongxuan/ptoas-board-monitor/runtime/runs/20260728_230819_manual_pr1027/payload/pto-isa/include/pto/common/pto_instr.hpp:67:15: note: candidate function template not viable: requires at most 2 arguments, but 3 were provided
PTO_INST void SYNCALL(GlobalData& gmWorkspace, int32_t usedCores = 0)
              ^
/home/zhongxuan/ptoas-board-monitor/runtime/runs/20260728_230819_manual_pr1027/payload/pto-isa/include/pto/common/pto_instr.hpp:53:15: note: candidate function template not viable: requires 0 arguments, but 3 were provided
PTO_INST void SYNCALL()
              ^
1 error generated.
gmake[2]: *** [CMakeFiles/syncall_binding_kernel.dir/build.make:76: CMakeFiles/syncall_binding_kernel.dir/syncall_binding_kernel.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/syncall_binding_kernel.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
[2026-07-28 23:35:06] ERROR: testcase failed (exit 2): syncall_binding
comm_p2p_binding_variants

stage=run info=exit=1

[ERROR] aclrtSynchronizeStream(stream) failed: 507035 (/home/zhongxuan/ptoas-board-monitor/runtime/runs/20260728_230819_manual_pr1027/npu_validation/CommSync/comm_p2p_binding_variants/main.cpp:122)
[ERROR] RecentErrMsg: EZ9999: Inner Error!
EZ9999[PID: 1612701] 2026-07-28-23:47:47.061.552 (EZ9999):  The error from device(chipId:0, dieId:1), serial number is 2335, there is an exception of aivec error, core id is 18, error code = 0x10, dump info: pc start: 0x124200000000, current: 0x124200000164, vec error info: 0x62000000b1, mte error info: 0x6d0600009a, ifu error info: 0x212c0bb6ac580, ccu error info: 0x40e008000000004f, cube error info: 0, biu error info: 0, aic error mask: 0x6500020bd00028c, para base: 0x12c100000000.[FUNC:PrintCoreInfo][FILE:device_error_core_proc.cc][LINE:645]
        TraceBack (most recent call last):
       The extend info: errcode:(0x10, 0, 0) errorStr: Illegal instruction, which is usually caused by unaligned UUB addresses. fixp_error0 info: 0x600009a, fixp_error1 info: 0x6d, fsmId:0, tslot:6, thread:0, ctxid:0, blk:0, sublk:0, subErrType:4.[FUNC:PrintCoreInfo][FILE:device_error_core_proc.cc][LINE:658]
       Kernel task happen error, retCode=0x31, [vector core exception].[FUNC:PreCheckTaskErr][FILE:davinci_kernel_task.cc][LINE:1729]
       AIV Kernel happen error, retCode=0x31.[FUNC:GetError][FILE:stream.cc][LINE:1475]
       [AIC_INFO] after execute:args print end[FUNC:GetError][FILE:stream.cc][LINE:1475]
       [DFX_INFO]Aicore kernel execute failed, device_id=1, stream_id=46, report_stream_id=46, task_id=0, flip_num=0, fault kernel_name=comm_p2p_binding_variants_kernel, fault kernel info ext=comm_p2p_binding_variants_kernel, program id=0, hash=16541545288638093324.[FUNC:GetError][FILE:stream.cc][LINE:1475]
       rtStreamSynchronize execution failed, reason=vector core exception[FUNC:FuncErrorReason][FILE:error_message_manage.cc][LINE:65]
       synchronize stream failed, runtime result = 507035[FUNC:ReportCallError][FILE:log_inner.cpp][LINE:148]
[2026-07-28 23:47:48] ERROR: testcase failed (exit 1): comm_p2p_binding_variants
comm_p2p

stage=run info=exit=1

[ERROR] aclrtSynchronizeStream(stream) failed: 507035 (/home/zhongxuan/ptoas-board-monitor/runtime/runs/20260728_230819_manual_pr1027/npu_validation/CommSync/comm_p2p/main.cpp:122)
[ERROR] RecentErrMsg: EZ9999: Inner Error!
EZ9999[PID: 1630951] 2026-07-28-23:48:05.940.555 (EZ9999):  The error from device(chipId:0, dieId:1), serial number is 2336, there is an exception of aivec error, core id is 23, error code = 0x10, dump info: pc start: 0x124200000000, current: 0x124200000168, vec error info: 0x4000000b7, mte error info: 0xa5030030d0, ifu error info: 0x212cf84100200, ccu error info: 0x40e008000000004f, cube error info: 0, biu error info: 0, aic error mask: 0x6500020bd00028c, para base: 0x12c100000000.[FUNC:PrintCoreInfo][FILE:device_error_core_proc.cc][LINE:645]
        TraceBack (most recent call last):
       The extend info: errcode:(0x10, 0, 0) errorStr: Illegal instruction, which is usually caused by unaligned UUB addresses. fixp_error0 info: 0x30030d0, fixp_error1 info: 0xa5, fsmId:0, tslot:6, thread:0, ctxid:0, blk:0, sublk:0, subErrType:4.[FUNC:PrintCoreInfo][FILE:device_error_core_proc.cc][LINE:658]
       Kernel task happen error, retCode=0x31, [vector core exception].[FUNC:PreCheckTaskErr][FILE:davinci_kernel_task.cc][LINE:1729]
       AIV Kernel happen error, retCode=0x31.[FUNC:GetError][FILE:stream.cc][LINE:1475]
       [AIC_INFO] after execute:args print end[FUNC:GetError][FILE:stream.cc][LINE:1475]
       [DFX_INFO]Aicore kernel execute failed, device_id=1, stream_id=46, report_stream_id=46, task_id=0, flip_num=0, fault kernel_name=comm_p2p_kernel, fault kernel info ext=comm_p2p_kernel, program id=0, hash=6260346515940177617.[FUNC:GetError][FILE:stream.cc][LINE:1475]
       rtStreamSynchronize execution failed, reason=vector core exception[FUNC:FuncErrorReason][FILE:error_message_manage.cc][LINE:65]
       synchronize stream failed, runtime result = 507035[FUNC:ReportCallError][FILE:log_inner.cpp][LINE:148]
[2026-07-28 23:48:07] ERROR: testcase failed (exit 1): comm_p2p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] PTOAS 支持 pto-isa 中的Layout::NZ 推断

2 participants